package com.ruoyi.edit.mapper;

import java.util.List;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.edit.domain.CourseContent;
import com.ruoyi.edit.domain.VendorCourseRel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 活动课内容Mapper接口
 * 
 * @author qiufeng
 * @date 2022-03-19
 */
public interface CourseContentMapper 
{
    /**
     * 查询活动课内容
     * 
     * @param id 活动课内容主键
     * @return 活动课内容
     */
    @DataSource(value = DataSourceType.SLAVE)
    public CourseContent selectCourseContentById(String id);

    /**
     * 查询活动课内容列表
     * 
     * @param courseContent 活动课内容
     * @return 活动课内容集合
     */
    @DataSource(value = DataSourceType.SLAVE)
    public List<CourseContent> selectCourseContentList(CourseContent courseContent);

    /**
     * 新增活动课内容
     * 
     * @param courseContent 活动课内容
     * @return 结果
     */
    @DataSource(value = DataSourceType.SLAVE)
    public int insertCourseContent(CourseContent courseContent);

    /**
     * 修改活动课内容
     * 
     * @param courseContent 活动课内容
     * @return 结果
     */
    @DataSource(value = DataSourceType.SLAVE)
    public int updateCourseContent(CourseContent courseContent);

    /**
     * 删除活动课内容
     * 
     * @param id 活动课内容主键
     * @return 结果
     */
    @DataSource(value = DataSourceType.SLAVE)
    public int deleteCourseContentById(String id);

    /**
     * 批量删除活动课内容
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    @DataSource(value = DataSourceType.SLAVE)
    public int deleteCourseContentByIds(String[] ids);


    @DataSource(value = DataSourceType.SLAVE)
    @Select(" select id, created, deleted, content, title, vendorId, vendorPackageId,`type` from tc_course_content where vendorPackageId = #{vendorPackageId}  " +
            "and  type = #{type}")
    CourseContent getVendorPackageIdAndType(@Param("vendorPackageId") String vendorPackageId,@Param("type") String type);


    @DataSource(value = DataSourceType.SLAVE)
    @Select(" select `id`, `created`, `deleted`, `content`, `title`, `vendorId`, `vendorPackageId`, `type`, `courseId`, `orderNum`, `durations`," +
            " `parentId`, `beginAt`, `endAt`, `remark`, `cover`, `tools`, `menuStyle`, `parentType`, `createdBy`, `createdName` " +
            " ,details,detailsType,categoryType  from tc_course_content where vendorPackageId = #{vendorPackageId} and deleted = 0   ")
    List<CourseContent> getVendorPackageId(@Param("vendorPackageId") String vendorPackageId);

    /**
     * 批量添加
     */
    @DataSource(value = DataSourceType.SLAVE)
    int batchCourseContent(List<CourseContent> list);

}

